package top.wshape1.rpc.filter;

import top.wshape1.rpc.common.exception.RpcException;
import top.wshape1.rpc.message.RpcMessage;
import top.wshape1.rpc.message.RpcRequest;

/**
 * @author Wshape1
 * @version 1.0
 * @description transform request message
 * @since 2024-02-15
 */

public abstract class AbstractRequestFilter implements Filter {

    @Override
    public boolean doFilter(RpcMessage message, FilterChain filterChain) throws RpcException {
        if (!(message instanceof RpcRequest)) {
            throw new RpcException("RequestFilter only support RpcRequest");
        }
        return doFilter((RpcRequest) message, filterChain);
    }

    public abstract boolean doFilter(RpcRequest request, FilterChain filterChain) throws RpcException;

}
